/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import dkvklocka.SerialListener;
import java.util.Observable;
import java.util.Observer;

/**
 *
 * @author max.gabrielsson
 */
public class SerialTester implements Observer{
    private SerialListener serialListener;

    public SerialTester() {
        serialListener = new SerialListener();
        serialListener.initialize();
        serialListener.addObserver(this);
        
        System.out.println("Listening from häfvklockan:");
        
        Runtime.getRuntime().addShutdownHook(new Thread(){

            @Override
            public void run() {
                if( serialListener != null )
                    serialListener.close();
            }
        });
    }
    
    public static void main( String[] args ){
        new SerialTester();
    }

    @Override
    public void update(Observable o, Object arg) {
        final String s = ((SerialListener)o).getValue();
        System.out.print(s);
    }
}
